#include<iostream>
using namespace std;
class A
{
public:
	int bookId;
	char isBorrow;
	int h;
	int m;
	A(){ isBorrow = 'E'; }
};
int main()
{
	int n, i, tid, th, tm, num = 0, time = 0;
	char tisBorrow;
	cin >> n;
	A *arr = new A[1010];
	while(n)
	{
		scanf("%d %c %d:%d", &tid, &tisBorrow, &th, &tm);
		if(tid == 0)
		{
			cout << num << " ";
			if(num != 0)
			{
				int temp = double(time)/double(num) + 0.5;
				printf("%d\n", temp);
			}
			else
				cout << 0 << endl;
			time = 0;
			num = 0;
			n--;
			continue;
		}
		if(tisBorrow == 'S')
		{
			arr[tid].bookId = tid;
			arr[tid].h = th;
			arr[tid].m = tm;
			arr[tid].isBorrow = 'S';		
		}
		if(tisBorrow == 'E' && arr[tid].isBorrow == 'S')
		{
			time = time + 60*(th-arr[tid].h) + tm-arr[tid].m;
			num++;
			arr[tid].isBorrow = 'E';
		}
	}
	return 0;
}
